

def mostOften ( A ):
    '''unittest
    >>> mostOften([20, 10, 30, 30, 40, 10])
    10
    >>> mostOften([20])
    20
    >>> mostOften([1,1,1,1,1])
    1
    >>> mostOften([])        
    '''
    
    if not len(A):
        return
    
    B = []
    C = []
    for i in xrange(len(A)):
        if A[i] not in B:
            B.append(A[i])
            C.append(1)
        else:
            C[B.index(A[i])] += 1
    
    return B[C.index(max(C))] 
    
import doctest
doctest.testmod()